﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PromotionCreate.aspx.cs" Inherits="KSGJ.PromotionCreate" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="ie=9;ie=8" />
    <title></title>
    <script src="/ksgj/Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/jquery.loadthumb.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/jquery.smartWizard.min.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/AlertBox/jquery.artDialog.js?skin=blue" type="text/javascript"></script>
    <link href="/ksgj/css/smart_wizard.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/MainSet.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/From_Effect.css" rel="stylesheet" type="text/css" />
    <style type="text/css" media="screen">
        #AspNetPager a{text-decoration:none;}
        a{text-decoration:none;}
        a:hover{text-decoration:none;}
    </style>
    <script type="text/javascript" language="javascript">
        $(window.parent.document).find("#promotiongoodlist").load(function () {
            var main = $(window.parent.document).find("#promotiongoodlist");
            var loaddiv = $(window.parent.document).find("#goodload");
            var mparent = $(window.parent.document).find(".stepContainer");
            var thisheight = $(document).height() + 30;
            main.height(thisheight);
            mparent.height(thisheight + 46);
            loaddiv.hide();
            main.show();
        });

        function accSubtr(arg1, arg2) {
            var r1, r2, m, n;
            try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
            try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
            m = Math.pow(10, Math.max(r1, r2));
            //动态控制精度长度
            n = (r1 >= r2) ? r1 : r2;
            return ((arg1 * m - arg2 * m) / m).toFixed(n);
        }
        function accMul(arg1, arg2) {
            var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
            try { m += s1.split(".")[1].length } catch (e) { }
            try { m += s2.split(".")[1].length } catch (e) { }
            return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
        }


        function resizeImg() {
            var imgcount = $(".imgdiv img").length;
            for (var i = 0; i < imgcount; i++) {
                $($(".imgdiv img")[i]).loadthumb({
                    "src": $(".imgdiv img")[i].src,
                    "imgId": $(".imgdiv img")[i].id,
                    "parentId": $($(".imgdiv img")[i]).parent()[0].id
                });
            }
        }
        function onloadfun() {
            $("#AspNetPager a[disabled|=disabled]").addClass("paginate_button_disabled");
            $("a.btn").wrapInner("<span></span>");
            $("a.btn, button, .pager img").hover(function () {
                $(this).stop().fadeTo(200, 0.7);
            }, function () {
                $(this).stop().fadeTo(200, 1.0);
            });
            $("ul.gallery li").hover(function () {
                $(this).css("border-color", "#E6C26E");
                $(this).css("box-shadow", "0 0 2px #E6C26E");
            }, function () {
                $(this).css("border-color", "#c0c0c0");
                $(this).css("box-shadow", "0 0 2px rgba(0,0,0,0.25)");
            });
            $(".mark").mousedown(function () {
                $(this).addClass("checkbox-clicked");
            }).mouseup(function () {
                $(this).removeClass("checkbox-clicked");
            }).hover(function () {
                $(this).toggleClass("checkbox-hover");
            });
            $(".subcheck").change(function () {
                var subchk = $('.subcheck');
                var isallchk = (subchk.length == $(".subcheck:checked").length ? true : false);
                var gid = $(this).parent().parent().siblings("div").eq(1).children(".goodcontent").eq(0).children(":hidden").val();
                $("#allcheck").attr("checked", isallchk);
                if (isallchk) {
                    $("#allcheck").parent("label").addClass("checkbox-checked");
                }
                else {
                    $("#allcheck").parent("label").removeClass("checkbox-checked");
                }
                if (this.checked) {
                    $(this).parent("label").addClass("checkbox-checked");
                    $(this).parent().parent().parent("li").css("color", "#205A94");
                    if ($("#goodslist").val().indexOf(gid + ",") < 0) {
                        $("#goodslist").val(function (index, value) {
                            return value + gid + ",";
                        });
                    }
                }
                else {
                    $(this).parent("label").removeClass("checkbox-checked");
                    $(this).parent().parent().parent("li").css("color", "#222");
                    $("#goodslist").val(function (index, value) {
                        return value.replace(gid + ",", '');
                    });
                }
            });
            $("#allcheck").change(function () {
                var flag = this.checked;
                $('.subcheck').attr("checked", flag);
                if (flag) {
                    $(this).parent("label").addClass("checkbox-checked");
                    $('.subcheck').parent("label").addClass("checkbox-checked");
                    $('.subcheck').parent().parent().parent("li").css("color", "#205A94");
                    $('.subcheck').each(function () {
                        var sgid = $(this).parent().parent().siblings("div").eq(1).children(".goodcontent").eq(0).children(":hidden").val();
                        if ($("#goodslist").val().indexOf(sgid + ",") < 0) {
                            $("#goodslist").val(function (index, value) {
                                return value + sgid + ",";
                            });
                        }
                    });
                }
                else {
                    $(this).parent("label").removeClass("checkbox-checked");
                    $('.subcheck').parent("label").removeClass("checkbox-checked")
                    $('.subcheck').parent().parent().parent("li").css("color", "#222");
                    $('.subcheck').each(function () {
                        var sgid = $(this).parent().parent().siblings("div").eq(1).children(".goodcontent").eq(0).children(":hidden").val();
                        $("#goodslist").val(function (index, value) {
                            return value.replace(sgid + ",", '');
                        });
                    });
                }
            });
            $("#shopcheckbox").change(function () {
                var flag = this.checked;
                if (flag) {
                    $(this).parent("label").addClass("checkbox-checked");
                }
                else {
                    $(this).parent("label").removeClass("checkbox-checked");
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="goodslist" runat="server" />
    <asp:HiddenField ID="promotiontype" runat="server" />
    <asp:HiddenField ID="promotionvalue" runat="server" />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div>
                <div style="padding:0 10px;font-size:18px;color:#547EAB;margin-top:5px;">
                    <label class="checkbox" id="shoplabel" style="float:left;">
                        <input type="checkbox" id="shopcheckbox" class="shopcheck hidden" />
                        <span class="mark">
                            <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                        </span>全店参与
                    </label>
                    <label class="checkbox" id="alllabel" runat="server" style="float:right;margin-right:16px;">本页全选
                        <input type="checkbox" id="allcheck" class="allcheck hidden" runat="server" />
                        <span class="mark">
                            <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                        </span>
                    </label>
                    <div class="clearfix"></div>
                </div>
                <ul class="gallery" style="margin:0 0 10px 0;">
                    <asp:Repeater ID="goodlist" runat="server" 
                        onitemdatabound="goodlist_ItemDataBound">
                        <ItemTemplate>
                            <li id="goodli" runat="server" style="width:610px;">
                                <div class="imgdiv" id="imgdiv<%# Eval("numiid") %>" style="width:60px;height:60px;">
                                    <img id="<%# Eval("numiid") %>" src="<%# Eval("picurl") %>" alt="" style="display:none" />
                                </div>
                                <div style="float:left;width:480px;">
                                    <div class="goodcontent">
                                        <%# Eval("title").ToString().Trim()%>
                                        <asp:HiddenField ID="Hiddennid" runat="server" Value='<%# Eval("numiid") %>' />
                                    </div>
                                    <div class="goodcontent">
                                        价格：￥<span><%# Eval("price")%></span>&nbsp;&nbsp;&nbsp;优惠后价格：￥<span runat="server" id="afterprice"><%# Eval("price")%></span>&nbsp;&nbsp;&nbsp;<asp:Label
                                            ID="haspromotion" runat="server" Text="已经存在折扣活动" ForeColor="Red" Visible="false"></asp:Label>
                                    </div>
                                </div>
                                <div style="float:left;width:60px;text-align :center;height:60px;vertical-align:middle;">
                                    <label class="checkbox" id="sublabel" runat="server" style="margin:21px 0;">
                                        <input type="checkbox" id="subcheckbox" class="subcheck hidden" runat="server" />
                                        <span class="mark">
                                            <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                                        </span>
                                    </label>
                                </div>
                            </li>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="footlabel" runat="server" Text="此类目没有宝贝！" CssClass="nocount" Visible='<%# goodlist.Items.Count == 0 %>'></asp:Label>
                        </FooterTemplate>
                    </asp:Repeater>
                </ul>
            </div>
            <div>
                <webdiyer:aspnetpager id="AspNetPager" runat="server" HorizontalAlign="Center"
            Width="100%" CustomInfoHTML="共%PageCount%页，当前为第%CurrentPageIndex%页" CustomInfoTextAlign="Left" 
            Direction="LeftToRight" FirstPageText="首页" LastPageText="尾页" LayoutType="Div" 
            NextPageText="下一页" PageIndexBoxType="TextBox" PrevPageText="上一页" 
            ShowPageIndexBox="Never" PageSize="10" ShowNavigationToolTip="True" 
            EnableTheming="False" NumericButtonCount="6" 
                CurrentPageButtonPosition="Center" UrlPageIndexName="currpage" 
                Wrap="False" CurrentPageButtonClass="paginate_active" UrlPaging="False" 
                        AlwaysShow="True" 
                        FirstLastButtonsClass="first paginate_button" 
                        PagingButtonsClass="paginate_button" 
                        PrevNextButtonsClass="previous paginate_button" 
                        onpagechanging="AspNetPager_PageChanging"></webdiyer:aspnetpager>
            </div>          
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
